<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@include file="/common/definition.jsp"%>

<html:html>
<tiles:insert beanName="admin-definition" flush="true">
	<tiles:put name="title"> Administrator Management </tiles:put>
	<tiles:put name="body" type="string">
	<div class="mainHome" style="padding-top: 15px; min-height: 360px">
	<div class="row col-md-12" style="padding-top: 15px;">
		<div class="col-md-4">
			<s:form theme="simple">
				<div class="muted h3" style="padding-bottom: 15px;">Thương Hiệu</div>
				<ul
					style="width: 200px; height: 200px; overflow: auto; border: 1px solid #90bade;">
					<s:if test="productModel.listBrandInfo != null">
						<s:iterator value="productModel.listBrandInfo" id="list">
							<li><s:a action="viewBrand">
									<s:property value="brandName" />
									<s:param name="id" value="brandID" />
								</s:a></li>
							<%-- <a href="deleteBrand.action?id=${brandID}">Deleted</a></li> --%>
						</s:iterator>
					</s:if>
				</ul>
			</s:form>
		</div>
		<div class="col-md-5">
			<s:form name="editBrand" action="editBrand" theme="simple">
				<div class="muted h3" style="padding-bottom: 10px;">Chi tiết nhà sản xuất</div>
				<div class="col-sm-12" style="padding: 0px;">
					<div class="error_box"></div>
				</div>
				<s:if test="errorAddBrand == null || errorAddBrand == ''">
				</s:if>
				<s:elseif test="errorAddBrand != null">
					<div class="error_box" style="display: block;"><s:property value="errorAddBrand" /></div>
				</s:elseif>
				<s:property value="errorAddBrand" />
				<div class="form-group">
					<label>Mã số</label>
					<s:textfield name="brandInfo.brandID" disabled="true"
						cssClass="form-control" />
				</div>
				<div class="form-group">
					<label>Tên nhà sản xuất</label>
					<s:textfield name="brandInfo.brandName" cssClass="form-control" 
						data-toggle="tooltip" 
						title="Tên hãng sản xuất có độ dài từ 2 đến 20 ký tự"/>
				</div>
				<div class="form-group">
					<label>Website</label>
					<s:textfield name="brandInfo.website" cssClass="form-control"
						data-toggle="tooltip" 
						title="website của hãng sản xuất." />
				</div>
				<div style="padding-bottom: 10px;">
					<button class="btn btn-primary">Sửa</button>
					<button type="reset" class="btn btn-default">Nhập Lại</button>
				</div>
			</s:form>
			<script type="text/javascript">
			var validator = new FormValidator('editBrand', 
			[{
				name: 'brandInfo.brandName',  
				display: 'tên hãng sản xuất',
				rules: 'required|min_length[2]|max_length[20]'
			},{
				name: 'brandInfo.website',  
				display: 'website',
				rules: 'required|valid_url'
			}], function(errors, evt) {
						var SELECTOR_ERRORS = $('.error_box'),
						SELECTOR_SUCCESS = $('.success_box');
						
					if (errors.length > 0) {
						SELECTOR_ERRORS.empty();
						for (var i = 0, errorLength = errors.length; i < errorLength; i++) {
							SELECTOR_ERRORS.append(errors[i].message + '<br />');
						}
						
						SELECTOR_SUCCESS.css({ display: 'none' });
						SELECTOR_ERRORS.fadeIn(200);
					} else {
						SELECTOR_ERRORS.css({ display: 'none' });
						SELECTOR_SUCCESS.fadeIn(200);
					}			
				});
			</script>
		</div>
		</div>
		</div>
	</tiles:put>
</tiles:insert>
</html:html>
